<template>
  <div class="robot-tab-cont search-back">
    <iframe :src="iframeSrc" title="资信智能检索" id="iframe" style="width: 100%; height: 100%" />
  </div>
</template>
<script>
import windowConst from "@/utils/const";
import API from "../api-chat-window";
import { postCreditReview } from "@/api/index";
import qs from "qs";
export default {
  data() {
    return {
      iframeSrc: windowConst.VUE_APP_ZXHC_SEARCH_URL,
    };
  },
  methods: {
    async UserInfo() {
      // 请求人员信息
      const userData = await API.getUserInfo({});
      const { companyName, departmentDN, userID, userName } = userData.data;
      const params = {
        appId: "lawbot", // 应用ID
        companyName, // 请求人所在公司
        departmentDN, // 请求人所在部门
        userID, // 用户id
        userName, // 用户名字
      };
      //这里先根据人员的信息再去请求资信审查token
      const { data } = await postCreditReview(params); //请求资信审查token
      const obj = { moduleId: "e6ad35235b", accessToken: data };// 模块id 和 资信审查token
      const queryString = qs.stringify(obj);
      this.iframeSrc = windowConst.VUE_APP_ZXHC_SEARCH_URL + `?${queryString}`;
    },
  },
  async created() {
    await this.UserInfo();
  },
};
</script>
